<template>
  <el-row v-loading="loading">
    <p><span>通道状态：</span><span class="fz12 tip">{{ date.enter_status }}</span></p>
    <p><span>状态信息：</span><span class="fz12 err">{{ date.error_info }}</span></p>
    <p>经营地址：{{ date.area }}</p>
    <p>详细地址：{{ date.address }}</p>
    <p>商户类别：{{ date.industry }}</p>
    <p>渠道选择：{{ date.balance_type }}</p>
    <p>D+0到账：{{ date.d0_cash ? '已开通' : '未开通' }}</p>
    <p>证件信息：</p>
    <div>
      <img width="100" height="100" class="mr20" title="商户协议" v-if="date.channel_starpos_agreement" :src="date.channel_starpos_agreement">
      <img width="100" height="100" class="mr20" title="商户信息表" v-if="date.channel_starpos_mch_info" :src="date.channel_starpos_mch_info">
      <img width="100" height="100" class="mr20" title="结算人站门头照" v-if="date.channel_starpos_stofc_payee" :src="date.channel_starpos_stofc_payee">
      <img width="100" height="100" class="mr20" title="协议书" v-if="date.ch_spos_certi" :src="date.ch_spos_certi">
      <img width="100" height="100" class="mr20" title="授权协议手持合照" v-if="date.ch_spos_certi_inhand" :src="date.ch_spos_certi_inhand">
    </div>
    <h4 v-if="date.card_type === 3" class="tip">POS机</h4>
    <p v-if="date.card_type === 3">借记卡费率：{{ date.debit }} %</p>
    <p v-if="date.card_type === 3">封顶金额：{{ date.pos_debit_max }} 元</p>
    <p v-if="date.card_type === 3">贷记卡费率：{{ date.credit }} %</p>
    <p v-if="date.card_type === 3">支持双免：{{ date.is_supt_dbfree_flg ? '已开通' : '未开通' }}</p>
    <p v-if="date.card_type === 3">支持卡种：<span v-for="item in date.support_card" :key="item">{{ item === 1 ? '借记卡，' : item === 0 ? '贷记卡': '无' }}</span></p>
    <p v-if="date.card_type === 3">交易类型：<span v-for="item in date.tran_types.code" :key="item">{{ item === 'C1' ? '消费，' : item === 'C2' ? '消费撤销，' : item === 'C3' ? '预授权，' : item === 'C4' ? '预授权完成，' : item === 'C5' ? '预授权完成撤销，' : item === 'C6' ? '预授权撤销，' : item === 'C7' ? '余额查询' : ''  }}</span></p>
    <p v-if="date.card_type === 3">终端数量：{{ date.trm_num }}</p>
    <p v-if="date.sp_trm_nos.length > 0">终端编号：<el-tooltip>{{ date.sp_trm_nos.slice(0,4).toString() + '...' }}<div slot="content"><p v-for="item in date.sp_trm_nos" :key="item">{{item}}</p></div> </el-tooltip>
    <h4 class="tip">移动支付</h4>
    <p>移动支付签约费率：{{ date.scan }}%<span class="err">（支付宝、微信）</span></p>
    <p>银联二维码标准费率：{{ date.unionpay_sta }}%<span class="err">（收款金额≥1000元）</span></p>
    <p>银联二维码优惠费率：{{ date.unionpay_dis }}%<span class="err">（收款金额&lt;1000元）</span></p>
  </el-row>
</template>

<script>
import { verfiryChannelMainlandQuery } from '@/api/shop'

export default {
  data() {
    return {
      loading: true,
      date: {
        card_type: '',
        area: '',
        address: '',
        industry: '',
        balance_type: '',
        d0_cash: '',
        credit: '',
        pos_debit_max: '',
        debit: '',
        support_card: [],
        tran_types: [],
        trm_num: '',
        channel_starpos_agreement: '',
        scan: '',
        unionpay_dis: '',
        unionpay_sta: '',
        enter_status: null,
        error_info: '',
        channel_starpos_mch_info: '',
        channel_starpos_stofc_payee: '',
        sp_trm_nos: []
      }
    }
  },
  methods: {
    handleDocumentInit() {
      verfiryChannelMainlandQuery(this.$route.query.merchant_num).then(res => {
        if (res.data.errorCode === 0) {
          this.loading = false
          this.date.area = res.data.result.area.name.toString()
          this.date.address = res.data.result.address
          this.date.card_type = res.data.result.card_type
          this.date.industry = res.data.result.industry
          this.date.d0_cash = res.data.result.d0_cash
          this.date.credit = res.data.result.credit
          this.date.pos_debit_max = res.data.result.pos_debit_max
          this.date.debit = res.data.result.debit
          this.date.support_card = res.data.result.support_card
          this.date.tran_types = res.data.result.tran_types
          this.date.trm_num = res.data.result.trm_num
          this.date.channel_starpos_agreement = res.data.result.photo.channel_starpos_agreement
          this.date.scan = res.data.result.scan
          this.date.unionpay_dis = res.data.result.unionpay_dis
          this.date.unionpay_sta = res.data.result.unionpay_sta
          this.date.balance_type = res.data.result.balance_type
          this.date.error_info = res.data.result.enter_status.error_info
          this.date.enter_status = res.data.result.enter_status.name
          this.date.channel_starpos_stofc_payee = res.data.result.channel_starpos_stofc_payee
          this.date.channel_starpos_mch_info = res.data.result.channel_starpos_mch_info
          this.date.sp_trm_nos = res.data.result.sp_trm_nos
        } else {
          this.$message.error(res.data.errorMsg)
        }
      })
    }
  },
  created() {
    this.handleDocumentInit()
  }
}
</script>

